using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Portal.GUI.EditoralOffice.MainOffce.editnews.k14
{
    public partial class ListNews : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Portal.BO.Editoral.Category.CategoryHelper.TreebuildAllCat(cboCategory);

                objListNewsSource.SelectParameters["strWhere"].DefaultValue = GetWhere();
            }
            
        }

        private string GetWhere()
        {
            string strWhere = " News_Status = 3 ";
            if (txtKeyword.Text.Trim() != "")
            {
                strWhere += " AND News_Title like N'%"+ txtKeyword.Text.Trim() +"%' ";
            }
            if (cboCategory.SelectedValue != "" && cboCategory.SelectedValue != "0")
            {
                strWhere += " AND Cat_ID =  " + cboCategory.SelectedValue;
            }

            return strWhere;
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            objListNewsSource.SelectParameters["strWhere"].DefaultValue = GetWhere();
        }
    }
}